﻿using Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace App.Forms
{
    public partial class Fastcash : Form
    {
        public Fastcash()
        {
            InitializeComponent();
        }

        private void Fastcash_Load(object sender, EventArgs e)
        {
            
        }

        private void btnSelect20_Click(object sender, EventArgs e)
        {
            Withdraw(20);
        }
        private void Withdraw(int amount)
        {
            TaskManager tm = new TaskManager();
            txtmsg.Visible = true;
            txtmsg.ForeColor = System.Drawing.Color.Red;
            string msg = "";
          
                try
                {
                    msg = tm.WithDrawMoney(Model.CurrentSession.currentAccount, amount);
                    if (msg == "Success")
                    {
                        msg = "Withdrawal Successfully completed \n Amount: " + amount;
                        txtmsg.ForeColor = System.Drawing.Color.Green;
                    }
                }
                catch (Exception)
                {

                    throw;
                }

            txtmsg.Text = msg;
        }
        private void btnSelectOther_Click(object sender, EventArgs e)
        {
            this.Hide();
            var frm = new Cashwithdraw();
            frm.Closed += (s, args) => this.Close();
            frm.Show();
        }

        private void btnSelect50_Click(object sender, EventArgs e)
        {
            Withdraw(50);
        }
    }
}
